import java.util.ArrayList;

class MyArray<T> {
    public Object[] array = new Object[5];

    public void set(int pos,T val) {
        array[pos] = val;
    }

    public T getVal(int pos) {
        return (T)array[pos];
    }
}

public class Test2 {
    public static void main(String[] args) {
        MyArray<Integer> myArray = new MyArray<>();
        myArray.set(0,12);
        myArray.set(1,23);
        Integer ret = myArray.getVal(1);
        System.out.println(ret);

        MyArray<String> myArray2 = new MyArray<>();
        myArray2.set(0,"hello");
        myArray2.set(1,"world");

        String s = myArray2.getVal(1);
        System.out.println(s);


        ArrayList<Integer> arrayList1 = new ArrayList<>();
        ArrayList<String> arrayList2 = new ArrayList<>();
        ArrayList<Double> arrayList3 = new ArrayList<>();


    }

    public static void main1(String[] args) {
        MyArray myArray = new MyArray();
        myArray.set(0,12);
        myArray.set(1,"apple");

        String s = (String)myArray.getVal(1);
        System.out.println(s);
    }
}
